<template>
<slot :controller="controller" :store="store" :model="model">
    <div :class="classNames">
        <slot name="container_scroll1Container" :controller="controller" :store="store" :model="model" >
        <AppScrollContainer 
            name="container_scroll1"
            :layoutModelDetails="store.layoutModelDetails">
            <template #container_scroll_main1>
                <slot name="container_scroll_main1Container" :controller="controller" :store="store" :model="model" >
                <AppScrollContainer 
                    name="container_scroll_main1"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #container2>
                        <slot name="container2Container" :controller="controller" :store="store" :model="model" >
                        <AppStandardContainer 
                            name="container2"
                            v-show="store.layoutModelDetails?.container2?.visible"
                            :isMultiContainer="false"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #button_calluilogic2>
                                <slot name="button_calluilogic2" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetButton
                                    name="button_calluilogic2"
                                    :loading="store.loadingHelper.isLoading"
                                    :layoutModelDetails="store.layoutModelDetails"
                                    :value="store.layoutData.button_calluilogic2"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    />
                                </slot>
                            </template>
                            <template #field_textbox>
                                <slot name="field_textbox" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPanelField
                                    name="field_textbox"
                                    :value="store.layoutData.field_textbox"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    <slot name="field_textboxEditor" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                    <AppInput
                                        v-bind="{ editorType: 'TEXTBOX', }"
                                        type="text"
                                        style=""
                                        name="field_textbox"
                                        :isDebounce="true"
                                        :disabled="store.layoutModelDetails.field_textbox?.disabled ? true : false"
                                        :value="store.layoutData.field_textbox"
                                        @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    />
                                    </slot>
                                </AppPanelField>
                                </slot>
                            </template>
                            <template #searchbar>
                                <slot name="searchbar" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                <AppCtrlPos name="searchbar" :layoutModelDetails="store.layoutModelDetails">
                                    </AppCtrlPos>
                                </slot>
                            </template>
                            <template #button_calluilogic3>
                                <slot name="button_calluilogic3" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetButton
                                    name="button_calluilogic3"
                                    :loading="store.loadingHelper.isLoading"
                                    :layoutModelDetails="store.layoutModelDetails"
                                    :value="store.layoutData.button_calluilogic3"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    />
                                </slot>
                            </template>
                            <template #button_calluilogic4>
                                <slot name="button_calluilogic4" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetButton
                                    name="button_calluilogic4"
                                    :loading="store.loadingHelper.isLoading"
                                    :layoutModelDetails="store.layoutModelDetails"
                                    :value="store.layoutData.button_calluilogic4"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    />
                                </slot>
                            </template>
                        </AppStandardContainer>
                        </slot>
                    </template>
                    <template #grid>
                        <slot name="grid" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                        <AppCtrlPos name="grid" :layoutModelDetails="store.layoutModelDetails">
                            <slot name="IBIZOrderMainGrid" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                            <IBIZOrderMainGrid
                                
                                :actions="{
                                    loadDraftAction: 'GetDraft',
                                    createAction: 'Create',
                                    fetchAction: 'FetchDefault',
                                    removeAction: 'Remove',
                                    updateAction: 'Update'
                                }"
                                :defaultEnableRowEdit="model.rowEditDefault"
                                :openView="store.openView"
                                :newView="store.newView"
                                :singleSelect="false"
                                name="grid"
                                v-bind="model.ctrlParams.IBIZOrdergrid"
                                :context="store.context"
                                :viewParams="store.viewParams"
                                :closeView="store.closeView"
                                :pLoadingHelper="store.loadingHelper"
                                :pViewCtx="store.viewCtx"
                                @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                                @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                                @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"></IBIZOrderMainGrid>
                            </slot>
                            </AppCtrlPos>
                        </slot>
                    </template>
                    <template #grid2>
                        <slot name="grid2" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                        <AppCtrlPos name="grid2" :layoutModelDetails="store.layoutModelDetails">
                            <slot name="IBIZBOOKMain3Grid" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                            <IBIZBOOKMain3Grid
                                
                                :actions="{
                                    loadDraftAction: 'GetDraft',
                                    createAction: 'Create',
                                    fetchAction: 'FetchDefault',
                                    removeAction: 'Remove',
                                    updateAction: 'Update'
                                }"
                                :defaultEnableRowEdit="model.rowEditDefault"
                                :openView="store.openView"
                                :newView="store.newView"
                                :singleSelect="false"
                                name="grid2"
                                v-bind="model.ctrlParams.IBIZBOOKgrid2"
                                :context="store.context"
                                :viewParams="store.viewParams"
                                :closeView="store.closeView"
                                :pLoadingHelper="store.loadingHelper"
                                :pViewCtx="store.viewCtx"
                                @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                                @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                                @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"></IBIZBOOKMain3Grid>
                            </slot>
                            </AppCtrlPos>
                        </slot>
                    </template>
                </AppScrollContainer>
                </slot>
            </template>
            <template #container_scroll_header1>
                <slot name="container_scroll_header1Container" :controller="controller" :store="store" :model="model" >
                <AppScrollContainer 
                    name="container_scroll_header1"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #container_image1>
                        <slot name="container_image1Container" :controller="controller" :store="store" :model="model" >
                        <AppScrollContainer 
                            name="container_image1"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #static_text1>
                                <slot name="static_text1" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetText 
                                    name="static_text1"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    :layoutModelDetails="store.layoutModelDetails" />
                                </slot>
                            </template>
                            <template #static_text2>
                                <slot name="static_text2" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetText 
                                    name="static_text2"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    :layoutModelDetails="store.layoutModelDetails" />
                                </slot>
                            </template>
                            <template #container1>
                                <slot name="container1Container" :controller="controller" :store="store" :model="model" >
                                <AppStandardContainer 
                                    name="container1"
                                    v-show="store.layoutModelDetails?.container1?.visible"
                                    :isMultiContainer="false"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    <template #button_calluilogic1>
                                        <slot name="button_calluilogic1" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                        <AppPresetButton
                                            name="button_calluilogic1"
                                            :loading="store.loadingHelper.isLoading"
                                            :layoutModelDetails="store.layoutModelDetails"
                                            :value="store.layoutData.button_calluilogic1"
                                            @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                            />
                                        </slot>
                                    </template>
                                </AppStandardContainer>
                                </slot>
                            </template>
                            <template #field_switch>
                                <slot name="field_switch" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPanelField
                                    name="field_switch"
                                    :value="store.layoutData.field_switch"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    <slot name="field_switchEditor" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                    <AppSwitch
                                        v-bind="{ editorType: 'SWITCH', }"
                                        style=""
                                        name="field_switch"
                                        :disabled="store.layoutModelDetails?.field_switch?.disabled ? true : false"
                                        :value="store.layoutData.field_switch"
                                        @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    />
                                    </slot>
                                </AppPanelField>
                                </slot>
                            </template>
                        </AppScrollContainer>
                        </slot>
                    </template>
                </AppScrollContainer>
                </slot>
            </template>
        </AppScrollContainer>
        </slot>
    </div>
</slot>
</template>
<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@DECUSTOMVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppCtrlPos, AppScrollContainer, AppSimpleFlexContainer, AppStandardContainer, AppTabPanel, AppTabPage } from '@components/layout-element/structure';

import IBIZOrderMainGrid from '@widgets/ibiz-order/main-grid/main-grid.vue';
import IBIZBOOKMain3Grid from '@widgets/ibizbook/main-3-grid/main-3-grid.vue';
import { useProps, useBasic, useAction, useController } from './ibiz-ordermyorder-custom-view-hook';
import { IEvent, CustomViewActionType, ICustomViewAbility, ICustomViewStore, IParam } from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    getClassNames, 
    useNavParamsBind,
	useEventBind,
    handleQuickSearch,
  	handleToolbarItemClick,
    handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy
} = useBasic(props);

const emit = defineEmits<{
    (event: 'view-action', name: string, action: CustomViewActionType, data: IParam[]): void;
    (event: 'view-init', name: string, data: ICustomViewAbility): void;
    (event: 'view-mounted', name: string, data: IParam): void;
    (event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: ICustomViewStore = controller.getStore();

onMounted(() => {
    controller.viewMounted();
})

onUnmounted(() => {
    controller.viewDestroy();
})
</script>
